<?php
$cheque_no = $_REQUEST["cheque_no"];
$tblname = $_REQUEST["tblname"];
?>

<script type="text/javascript">
    $(document).ready(function() {
        $("#cheque_paid_date").datepicker({
            dateFormat: "yy-mm-dd"
        });

        $("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
            submitSuccess: function($form, event) {
                event.preventDefault();
                //alert("success");

                var tblname = $("#tblname").val();

                switch (tblname) {
                    case "tbl_pet":
                        var file_process = "cheque_process.php";
                        var pages = "cheque_manage";
                        break;

                    case "tbl_petition":
                        var file_process = "cheque_process_petition.php";
                        var pages = "cheque_manage";
                        break;

                    case "tbl_salary":
                        var file_process = "cheque_process_salary.php";
                        var pages = "cheque_manage";
                        break;

                }
                //alert(tblname);
                $.ajax({
                    type: "POST",
                    url: file_process,
                    data: $('#frm_main').serialize(),
                    cach: false,
                    error: function() {
                        alert("ERROR !!!!");
                    },
                    success: function(data) {
                        //alert(data);
                        window.location.href = "index.php?pages=" + pages + "&tblname=" + tblname;

                    }
                });
            }
        });
    });
</script>
<form method="post" id="frm_main" name="frm_main" novalidate>
    <div class="control-group">
        <label>วันที่</label>
        <div class="controls">
            <input type="text" id="cheque_paid_date" name="cheque_paid_date" required>
        </div>
    </div>
    <div class="control-group">
        <label>ชื่อผู้รับเช็ค</label>
        <div class="controls">
            <input type="text" id='receiver_sign' name='receiver_sign' required>
        </div>
    </div>

    <div class="form-actions">
        <input type="hidden" id="cheque_no" name="cheque_no" value="<?php echo $cheque_no; ?>">
        <input type="hidden" id="tblname" name="tblname" value="<?php echo $tblname; ?>">
        <input type="hidden" id="task" name="task" value="paid">

        <button type="submit" class="btn btn-info" id="save_changes" >บันทึกข้อมูล</button>
        <!--<input type="submit" class="btn btn-info" value="บันทึกข้อมูล">-->
        <a class="btn close-dialog"><i class="icon-remove"></i> ยกเลิก</a>

    </div>
</form>